package com.yst.suivi.data.reports;

import javax.ejb.CreateException;
import javax.ejb.EntityBean;

import com.yst.suivi.data.AbstractEntityBean;

/**
 * @author stolf
 * @ejb.bean name="Report" type="CMP" cmp-version="2.x" schema="report"
 *           local-jndi-name="ReportBean" view-type="local" primkey-field = "id"
 *           reentrant = "True"
 * @ejb.home generate="local"
 * @ejb.persistence table-name = "report"
 * @jboss.entity-command name = "key-generator"
 * @jboss.read-ahead eager-load-group = "most" strategy = "on-load"
 *                   page-size="25"
 * @jboss.load-group name="most"
 * @ejb.interface local-extends = "com.yst.suivi.data.util.NamedObject,
 *                javax.ejb.EJBLocalObject"
 * @ejb.finder signature="java.util.Collection findAll()" query="SELECT
 *             OBJECT(g) FROM report AS g"
 * @ejb.finder signature="java.util.Collection findByType(int type)" query="SELECT
 *             OBJECT(g) FROM report AS g where g.type=?1"
 */
public abstract class ReportBean extends AbstractEntityBean implements EntityBean
{
	public static final int GLOBAL_REPORT = 1;
	public static final int PROJECT_REPORT = 2;

	/**
	 * @return
	 * @throws CreateException
	 * @ejb.create-method view-type = "local"
	 */
	public String ejbCreate() throws CreateException
	{
		setType(GLOBAL_REPORT);
		return null;
	}

	public void ejbPostCreate()
	{
		// by default nothing to do
	}

	/**
	 * Return the primary key of the object
	 * 
	 * @ejb.interface-method view-type = "local"
	 * @ejb.persistence
	 * @jboss.jdbc-type type = "VARCHAR"
	 * @jboss.sql-type type = "VARCHAR(255)"
	 */
	public abstract String getId();

	/**
	 * Fix the primary key of the object. The method should be used only by the
	 * container
	 * 
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setId(String id);

	/**
	 * Return the name of the object
	 * 
	 * @ejb.interface-method view-type = "local"
	 * @ejb.persistence
	 * @jboss.load-group name="most"
	 * @jboss.jdbc-type type = "VARCHAR"
	 * @jboss.sql-type type = "VARCHAR(255)"
	 */
	public abstract String getNom();

	/**
	 * Fix the name of the user. The method should be used only by the container
	 * 
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setNom(String nom);

	/**
	 * Return the path of the report
	 * 
	 * @ejb.interface-method view-type = "local"
	 * @ejb.persistence
	 * @jboss.load-group name="most"
	 * @jboss.jdbc-type type = "VARCHAR"
	 * @jboss.sql-type type = "VARCHAR(255)"
	 */
	public abstract String getReportPath();

	/**
	 * Fix the report path. The method should be used only by the container
	 * 
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setReportPath(String path);

	/**
	 * Return the filename of the report
	 * 
	 * @ejb.interface-method view-type = "local"
	 * @ejb.persistence
	 * @jboss.load-group name="most"
	 * @jboss.jdbc-type type = "VARCHAR"
	 * @jboss.sql-type type = "VARCHAR(255)"
	 */
	public abstract String getFilename();

	/**
	 * Fix the report filename. The method should be used only by the container
	 * 
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setFilename(String path);

	/**
	 * Return the type of the report
	 * <UL>
	 * <LI> 1 : global reports, there is no criterion on the databse request
	 * <LI> 2 : project report, there is a criterion on the id of the project
	 * version
	 * </ul>
	 * 
	 * @ejb.interface-method view-type = "local"
	 * @ejb.persistence
	 * @jboss.load-group name="most"
	 */
	public abstract int getType();

	/**
	 * Fix the report type. The method should be used only by the container
	 * 
	 * @ejb.interface-method view-type = "local"
	 */
	public abstract void setType(int type);
}